<template>
  <div>
    <p>{{obj}}</p>
    <p>{{str}}</p>
    <button @click="changeStr">changStr</button>
  </div>
</template>

<script>
import { ref } from 'vue'
export default {
  setup() {
    // 定义一个obj变量
    const obj = ref({
      name: '李成玉',
      age: 60,
      desc: '要瞅着入土了',
      car: '劳斯莱斯'
    })
    // ref在setup函数中使用的时候需要.value
    console.log('obj', obj.value.name)
    const str = ref('我是王子俊')
    const changeStr = () => {
      console.log('str', str)
      str.value = '左胜达'
    }
    return {
      str,
      obj,
      changeStr
    }
  }
}
</script>

<style>

</style>
